﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BGRunner
{
    public partial class Form1 : Form
    {
        public Form1()
        {


            InitializeComponent();

            // 创建NotifyIcon实例
            NotifyIcon notifyIcon = new NotifyIcon();
            notifyIcon.Icon = new Icon("icon.ico");

            // 创建ContextMenu实例并添加菜单项
            ContextMenuStrip contextMenu = new ContextMenuStrip();
            contextMenu.Items.Add("菜单项1");
            contextMenu.Items.Add("菜单项2");

            // 设置NotifyIcon的ContextMenuStrip属性
            notifyIcon.ContextMenuStrip = new ContextMenuStrip();
            notifyIcon.ContextMenuStrip.Items.Add("菜单项11");
            notifyIcon.ContextMenuStrip.Items.Add("菜单项22");

            //// 设置ContextMenu的对齐方式为靠右显示
            //notifyIcon.ContextMenuStrip. += (sender, e) =>
            //{
            //    e.Cancel = true;
            //    Point pos = new Point(Screen.PrimaryScreen.WorkingArea.Width - notifyIcon.ContextMenuStrip.Width, 0);
            //    notifyIcon.ContextMenuStrip.Show(notifyIcon, pos);
            //};

            // 显示NotifyIcon
            notifyIcon.Visible = true;
        }



    }
}
